$(document).ready(function() {
    $("#unclebai2").removeClass("sub-menu-link").addClass("selected");
    window.random_code_index = 0;
    $("#defButton").click(function () {
        var randomN = getRandomNum();
        $("#merOrderNum").val(randomN);

    });

    //商户订单号
    $("#merOrderNum").val(getRandomNum());

    $.formValidator.initConfig({
        validatorgroup: "1",
        formid: "form",
        onerror: function (input1, input2) {
            return false;
        }
    });

    $("#tranCode").formValidator({
        onshow: " "
    }).inputValidator({
        min: 1,
        onerror: "交易码不允许为空！"
    });

    $("#merchantId").formValidator({
        onshow: " "
    }).inputValidator({
        min: 1,
        onerror: "商户ID不允许为空！"
    });
    $("#version").formValidator({
        onshow: " "
    }).inputValidator({
        min: 1,
        onerror: "版本号不允许为空！"
    });
    $("#charset").formValidator({
        onshow: " "
    }).inputValidator({
        min: 1,
        onerror: "编码！"
    });

    $("#signType").formValidator({
        onshow: " "
    }).inputValidator({
        min: 1,
        onerror: "报文加密方式不为空!"
    });


    $("#agentSingNo").formValidator({
        onshow: " "
    }).inputValidator({
        min: 1,
        onerror: "协议号不允许为空！"
    });
    $("#tranDateTime").formValidator({
        onshow : " "
    }).inputValidator({
        min : 1,
        onerror : "交易时间不允许为空！"
    });
});

    function getRandomNum() {
        window.random_code_base = ((['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J',
                'K', 'M', 'N'])[new Date().getMonth()])
            + '_' + (Math.random() * 10000000000 + '').substring(0, 4);
        return window.random_code_base + "_" + (window.random_code_index++);
    }
